#include "globalDefinitions.h"

T_DIMSE_BlockingMode    opt_blockMode = DIMSE_BLOCKING;
int                     opt_dimse_timeout = 0;
int                     opt_acse_timeout = 30;
OFCmdUnsignedInt   opt_sleepAfter = 0;
OFCmdUnsignedInt   opt_sleepDuring = 0;
OFCmdUnsignedInt   opt_maxPDU = ASC_DEFAULTMAXPDU;
OFBool             opt_useMetaheader = OFTrue;
E_TransferSyntax   opt_networkTransferSyntax = EXS_Unknown;
E_TransferSyntax   opt_writeTransferSyntax = EXS_Unknown;
E_GrpLenEncoding   opt_groupLength = EGL_recalcGL;
E_EncodingType     opt_sequenceType = EET_ExplicitLength;
E_PaddingEncoding  opt_paddingType = EPD_withoutPadding;
OFCmdUnsignedInt   opt_filepad = 0;
OFCmdUnsignedInt   opt_itempad = 0;
OFBool             opt_verbose = OFFalse;
OFBool            opt_debug = OFFalse;
OFBool            opt_bitPreserving = OFFalse;
OFBool            opt_ignore = OFFalse;
OFBool            opt_abortDuringStore = OFFalse;
OFBool            opt_abortAfterStore = OFFalse;
OFBool            opt_correctUIDPadding = OFFalse;
ostream *        logstream           = &COUT;
DVPSIPCClient *messageClient  = NULL; // global pointer to IPC message client, if present
OFCmdUnsignedInt opt_port = 0;

#define OFFIS_CONSOLE_APPLICATION    ""

void closeLog()
{
	ofConsole.setCout();
	ofConsole.split();
	if (logstream != &CERR)
	{
		*logstream << endl << OFDateTime::getCurrentDateTime() << endl << "terminating" << endl;
		delete logstream;
		logstream = &CERR;
	}
}

void errmsg(const char* msg, ...)
{
    va_list args;
	
    fprintf(stderr, "%s: ", OFFIS_CONSOLE_APPLICATION);
    va_start(args, msg);
    vfprintf(stderr, msg, args);
    va_end(args);
    fprintf(stderr, "\n");
}

void print(OFList<int>& l)
{
	for (OFListIterator(int) it = l.begin(); it != l.end(); it++)
		COUT << *it << " ";
	COUT << "\n";
}